package distributions;

import java.io.IOException;

public class NormalStream extends RandomStream
{
  private double Mean;
  private double StandardDeviation;
  private double z;

  public NormalStream(double paramDouble1, double paramDouble2)
  {
    this.Mean = paramDouble1;
    this.StandardDeviation = paramDouble2;
    this.z = 0.0D;
  }

  public NormalStream(double paramDouble1, double paramDouble2, int paramInt)
  {
    this.Mean = paramDouble1;
    this.StandardDeviation = paramDouble2;
    this.z = 0.0D;
    for (int i = 0; i < paramInt * 1000; i++)
      Uniform();
  }

  public NormalStream(double paramDouble1, double paramDouble2, int paramInt, long paramLong1, long paramLong2)
  {
    super(paramLong1, paramLong2);
    this.Mean = paramDouble1;
    this.StandardDeviation = paramDouble2;
    this.z = 0.0D;
    for (int i = 0; i < paramInt * 1000; i++)
      Uniform();
  }

  public double getNumber()
    throws IOException, ArithmeticException
  {
    double d1, d2;
    if (this.z != 0.0D)
    {
      d1 = this.z;
      this.z = 0.0D;
    }
    else
    {
      double d3;
      double d4;
      do
      {
        d3 = 2.0D * Uniform() - 1.0D;
        d4 = 2.0D * Uniform() - 1.0D;
        d2 = d3 * d3 + d4 * d4;
      }
      while (d2 >= 1.0D);
      d2 = Math.sqrt(-2.0D * Math.log(d2) / d2);
      d1 = d3 * d2;
      this.z = (d4 * d2);
    }
    return this.Mean + d1 * this.StandardDeviation;
  }
}

/* Location:           /tmp/dlpjava/dlpjava.jar
 * Qualified Name:     distributions.NormalStream
 * JD-Core Version:    0.6.0
 */